package com.the_ring.chapter12.adapter;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.lifecycle.Lifecycle;
import androidx.viewpager2.adapter.FragmentStateAdapter;

import com.the_ring.chapter12.MainActivity;
import com.the_ring.chapter12.fragment.PictureFragment;

import java.util.List;

public class PictureAdapter extends FragmentStateAdapter {

    private static final String TAG = "PictureAdapter";

    private List<String> picturePaths;

    public PictureAdapter(@NonNull FragmentManager fragmentManager, @NonNull Lifecycle lifecycle, List<String> picturePaths) {
        super(fragmentManager, lifecycle);
        this.picturePaths = picturePaths;
    }


    @NonNull
    @Override
    public Fragment createFragment(int position) {
        return PictureFragment.newInstance(position, picturePaths.get(position));
    }

    @Override
    public int getItemCount() {
        return picturePaths.size();
    }


}
